﻿using System;
using System.Collections.Generic;
using System.Web.Mvc;

namespace EasyUIMvc.ComboBox
{
    public class ComboBoxExtension : ExtensionBase
    {
        private readonly ComboBoxSettings _settings;
        private IDictionary<string, string> _values;

        public ComboBoxExtension(ComboBoxSettings settings) {
            _settings = settings;
        }
        public ComboBoxExtension Bind(IDictionary<string, string> values) {
            _values = values;
            return this;
        }

        public override string GetScripts()
        {
            throw new NotImplementedException();
        }
        public override MvcHtmlString GetHtml()
        {
            var combobox = GetTopTag("select", "easyui-combobox", _settings);
            foreach (KeyValuePair<string,string> opt in _values) {
                var option = new TagBuilder("option");
                option.MergeAttribute("value", opt.Key);
                option.SetInnerText(opt.Value);
                combobox.InnerHtml += option;
            }
            return MvcHtmlString.Create(combobox.ToString());
        }

    }
    public class ComboBoxSettings : SettingsBase
    {
    }
}
